<?php namespace Phpcmf\Controllers\Admin;

use Phpcmf\App;
use Phpcmf\Service;

class Config extends App
{
    public function index()
    {
        $data = Service::M('app')->get_config(APP_DIR);
        if (IS_AJAX_POST) {
            $post = Service::L('input')->post('data');
            Service::M('app')->save_config(APP_DIR, $post);
            return $this->_json(1, dr_lang('操作成功'));
        }
        Service::V()->assign([
            'menu' => Service::M('auth')->_admin_menu(
                [
                    '短信设置' => [APP_DIR . '/' . Service::L('Router')->class . '/index', 'fa fa-cog'],
                ]
            ),
            'data' => $data,
        ]);
        Service::V()->display('config.html');
    }
}
